package com.seashop.controller;

import com.seashop.response.ResponseBase;
import com.seashop.util.OSSUploadUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author moredln
 * @desc OSS存储控制器
 * @date 2020/11/29 12:35 下午
 */
@RestController
@RequestMapping("/aliyun/file")
@Api(tags = "阿里OSS存储服务")
@Slf4j
public class AliOSSController {

    @PostMapping("/uploadImage")
    @ApiOperation(value = "上传图片")
    @ApiImplicitParam(value = "图片文件", name = "file", dataType = "file", required = true)
    public ResponseBase upload(@RequestParam("file") MultipartFile file) {
        String url = OSSUploadUtil.uploadImage(file, "seashop");
        return ResponseBase.success(url);
    }

}
